package com.docMan.bean;

import com.docMan.dao.pojo.DocDirectory;
import com.docMan.service.DocDirectoryService;
import com.docMan.utils.SpringContextUtils;

public class UpdateDirRunnable implements Runnable {
	private DocDirectoryService docDirectoryService=(DocDirectoryService) SpringContextUtils.getObject("docDirectoryService");
	private DocDirectory docDirectory;
	private int fileCount;
	private int dirCount;
	private double large=0;
	private int dirId;
	public UpdateDirRunnable(DocDirectory docDirectory) {
		super();
		this.docDirectory = docDirectory;
	}
	
	public UpdateDirRunnable(int dirId,double large) {
		super();
		this.large = large;
		this.dirId = dirId;
	}
	
	public UpdateDirRunnable(int dirId,int fileCount, int dirCount, double large
			) {
		super();
		this.fileCount = fileCount;
		this.dirCount = dirCount;
		this.large = large;
		this.dirId = dirId;
	}

	@Override
	public void run() {
//		docDirectoryService.update(docDirectory);
		DocDirectory docDirectory=docDirectoryService.getById(dirId);
		docDirectory.setLarge(docDirectory.getLarge()+large);
		docDirectory.setFileCount(docDirectory.getFileCount()+fileCount);
		docDirectory.setDirectoryCount(docDirectory.getDirectoryCount()+dirCount);
		docDirectoryService.update(docDirectory);
	}

}
